#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int alternateDigitSum(int n) {
    int ans = 0;
    int res = n;
    while (res)
    {
        ans++;
        res /= 10;
    }
    int sum = 0;
    int y = 0;
    for (int i = ans; i >= 1; i--)
    {
        if (n)
        {
            y = n % 10;
            if (i % 2 == 1)
                sum += y;
            if (i % 2 == 0)
                sum -= y;
        }
        n /= 10;
    }
    return sum;
}

int main()
{
    int n = 0;
    scanf("%d", &n);
    int ans = alternateDigitSum(n);
    printf("%d\n", ans);
	return 0;
}